import {
    VuexModule,
    Module,
    Action,
    Mutation,
    getModule
} from 'vuex-module-decorators'
import store from '@/store'

export interface MenuState {
    /** 首页的menu被激活项 */
    homeMenuIndex: string
}

/** 定义模块内容 */
@Module({ dynamic: true, store, name: 'menu' })
class Menu extends VuexModule implements MenuState {
    public homeMenuIndex = 'home'

    @Mutation
    public SET_HOMEMENUINDEX(index: string) {
        this.homeMenuIndex = index
    }

    @Action
    public setHomeMenuIndex(index: string) {
        this.SET_HOMEMENUINDEX(index)
    }
}

export const menuModule = getModule(Menu)
